<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String status = request.getParameter("status");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base href="<%=basePath%>" />
<title>豪俊电脑商城</title>
<jsp:include page="/jsp/admin/common.jsp" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>resource/admin_css/main.css"/>
<script type="text/javascript">
$().ready(function(){

	/*页面为修改状态，对页面数据进行初始化*/
	var status = "<%=status %>";
	if(status == "E"){	//编辑状态
		
	}
	
	/*返回按钮事件*/
	$("#backButton").click(function(){
		location.href = basePath + "jsp/admin/vip/vip_list.jsp";
	});

	var $form = $("#form_add");

	/*表达验证配置*/
	$form.validate({
		rules: {
			name : "required",
			email : {
				required : true,
				email : true,
			}
		}
	});

	/*表单提交前操作*/
	$form.submit(onSubmit);
});

/*初始化数据*/
function initData(){

	var $post = $.post(basePath + "admin/member_add.do", data, callback,"json");
}

function onSubmit(){

	var $form = $("#form_add");
	if(!$form.valid()) return false;	//表单验证失败
	
	var data = {
		name : $("input[name='name']").val(),	//名称
		email : $("input[name='email']").val()	//email
	};
	
	var callback = function(_result){
		var url = encodeURI(basePath + "jsp/admin/vip/vip_list.jsp?type="+ _result.type +"&content=" + _result.content);
		location.href = url;
	};	//回调函数

	$form.find(":submit").prop("disabled", true);	//防止重复提交
	var $post = $.post(basePath + "admin/member_add.do", data, callback,"json");

	/*设置默认错误方法*/
	$post.error(function(){
		location.href = basePath + "jsp/admin/login.jsp";
	});
	
	/*异步传递成功后调用方法*/
	$post.complete(function(){
		$("#form_add").find(":submit").prop("disabled", false);	//防止重复提交
	});
	return false;
}
</script>
</head>
<body>
	<div class="path">
		<a href="">首页</a> &raquo; <% if("A".equals(status)){ %>添加会员<%} else if("E".equals(status)){%>编辑会员<%} %>
	</div>
	<form id="form_add" method="post">
		<table class="input tabContent">
			<tr>
				<th>
					<span class="requiredField">*</span>名称:
				</th>
				<td>
					<input type="text" name="name" class="text" maxlength="200" value="${member.name }"/>
				</td>
			</tr>
			<tr>
				<th>
					<span class="requiredField">*</span>E-mail:
				</th>
				<td>
					<input type="text" name="email" class="text" maxlength="200" value=""/>
				</td>
			</tr>
			<tr>
				<th>
					&nbsp;
				</th>
				<td>
					<input type="submit" class="button" value="确定" />
					<input type="button" id="backButton" class="button" value="返回"/>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>